//
//  LZUserTool.swift
//  halikaPeso
//
//  Created by L-zh on 2024/12/17.
//

import Foundation

class LZUserTool: NSObject {
    public static func getUser() -> LZLoginModel? {
        let user =  NSKeyedUnarchiver.unarchiveObject(withFile: userSavePath as String) as? LZLoginModel
        return user
    }
    
    public static func saveUser(loginModel:LZLoginModel?) {
        guard let loginModel = loginModel else {
            return
        }
        NSKeyedArchiver.archiveRootObject(loginModel , toFile: userSavePath as String)
    }
    
    public static func deleteUser() {
        if FileManager.default.fileExists(atPath: userSavePath as String) {
            do {
                try FileManager.default.removeItem(atPath: userSavePath as String)
            }catch{
                
            }
            
        }
    }
    public static func isLogin() -> Bool {
        let userModel = getUser()
        if userModel?.token ?? "" == "" {
            return false
        }
        return true
    }
}
